#ifndef __ELF32_H
#define __ELF32_H
#include"global.h"

#define E_IDENT "\177ELF\1\1\1"



typedef uint32_t Elf32_Word,Elf32_Addr,Elf32_Off;
typedef uint16_t Elf32_Half;

struct Elf32_Ehdr{
	uint8_t e_ident[16];
	Elf32_Half e_type;
	Elf32_Half e_machine;
	Elf32_Word e_version;
	Elf32_Addr e_entry;
	Elf32_Off e_phoff;
	Elf32_Off e_shoff;
	Elf32_Word e_flags;
	Elf32_Half e_ehsize;
	Elf32_Half e_phentsize;
	Elf32_Half e_phnum;
	Elf32_Half e_shentsize;
	Elf32_Half e_shnum;
	Elf32_Half e_shstrndx;
};

struct Elf32_Phdr{
	Elf32_Word p_type;
	Elf32_Off  p_offset;
	Elf32_Addr p_vaddr;
	Elf32_Addr p_paddr;
	Elf32_Word p_filesz;
	Elf32_Word p_memsz;
	Elf32_Word p_flags;
	Elf32_Word p_align;
};

//elf segment type
enum segment_type{
	PT_NULL,
	PT_LOAD,
	PT_DYNAMIC,
	PT_INTERP,
	PT_NOTE,
	PT_SHLIB,
	PT_PHDR
};

//elf object file type
enum obj_type{
	ET_NOTE,
	ET_REL,
	ET_EXEC,
	ET_DYN,
	ET_CORE
};

//elf file for which cpu arch
enum arch_type{
	EM_NONE,
	EM_M32,
	EM_SPARC,
	EM_386,
	EM_68K,
	EM_88K,
	EM_860,
	EM_MIPS	
};

uint32_t load_elf32_exec(const char* path);

#endif
